package org.rohmh.category.domain;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.IndexColumn;
import org.rohmh.generic.entity.UUIDEntity;
import org.rohmh.user.domain.Member;


@Entity
@Table(name="rohmh_category")
public class RohmhCategory extends UUIDEntity<RohmhCategory> {

    @Column(name = "object_identity", unique = true, nullable = false)
    private String object_identity;


    private RohmhCategory parent_object;


	private List<RohmhCategory> children;

    private String acl_class;

	protected RohmhCategory() {
		// TODO Auto-generated constructor stub
	}

    public RohmhCategory(String object_identity, RohmhCategory parent_object, String acl_class) {
        this.object_identity = object_identity;
        this.parent_object = parent_object;
        this.acl_class = acl_class;
    }

    public RohmhCategory(String object_identity, String acl_class) {
        this.object_identity = object_identity;
        this.acl_class = acl_class;
    }

    public UUID getId() {
		return super.getUUID();
	}

    public void setId(UUID uuid) {
		super.setUUID(uuid);
	}

	@OneToMany(cascade=CascadeType.ALL, fetch = FetchType.EAGER)
	@Cascade( { org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN } )
	@JoinColumn(name="parent_object", nullable=true)
	public List<RohmhCategory> getChildren() {
	   return children;
	}

	public void setChildren(List<RohmhCategory> children) {
	   this.children = children;
	}
	
    public String getObject_identity() {
		return object_identity;
	}

    public void setObject_identity(String objectIdentity) {
		object_identity = objectIdentity;
	}

	@ManyToOne()
	@JoinColumn(name="parent_object", insertable=false, updatable=false, nullable=true)
    public RohmhCategory getParent_object() {
		return parent_object;
	}

    public void setParent_object(RohmhCategory parentObject) {
		parent_object = parentObject;
	}

    public String getAcl_class() {
		return acl_class;
	}

    public void setAcl_class(String aclClass) {
		acl_class = aclClass;
	}

}
